/*! \file
 * \brief Empty.
 * \author Ivo Wingelaar
 * \date 2011
 * \version 0.1.0
 * \copyright GNU Lesser General Public License v3
 */

#ifndef __MYTH_RANDOM_RANDOM_ALGORITHM_MERSENNE_TWISTER_C_HPP_INCLUDED__
#define __MYTH_RANDOM_RANDOM_ALGORITHM_MERSENNE_TWISTER_C_HPP_INCLUDED__

#include "MythRandom_AlgorithmStub_C.hpp"

namespace Myth
{
namespace Random
{

/** class                                 **/
/** AlgorithmMersenneTwister19937_C **/
//! A mersenne twister random number generator.
class AlgorithmMersenneTwister19937_C : public AlgorithmStub_C
{
public:
    /** constructor **/
    /// \param   int32_t seed
    ///         The seed you want to initialize the generator with.
    AlgorithmMersenneTwister19937_C( int32_t seed);

    /** default destructor **/
    virtual ~AlgorithmMersenneTwister19937_C();

    /** virtual function **/
    /** random_init      **/
    //! Initializes the generator with a new seed.
    /// \return void
    /// \param   int32_t seed
    ///         The seed to initialize the generator with.
    virtual void random_init( int32_t seed);

    /** virtual function **/
    /** get_random_int   **/
    //! Returns a random number in the interval [min, max].
    /// \return int32_t
    ///         A number between min and max (inclusive).
    /// \param   int32_t min
    ///         The smallest number allowed.
    /// \param   int32_t max
    ///         The largest number allowed.
    virtual int32_t get_random_int( int32_t min,
                                int32_t max);

    /** virtual function **/
    /** get_random_bytes **/
    //! Return 32 random bits.
    /// \return uint32_t
    ///         32 random bits.
    /// \param  void
    virtual uint32_t get_random_bytes(void);

private:
    //! State vector.
    uint32_t mMt[624];
    //! Index into mMt.
    uint32_t mTi;
    //! Last interval length.
    uint32_t mLastInterval;
    //! Rejection limit.
    uint32_t mRLimit;
};

/** class                                  **/
/** AlgorithmMersenneTwister11213A_C **/
//! A mersenne twister random number generator.
class AlgorithmMersenneTwister11213A_C : public AlgorithmStub_C
{
public:
    /** constructor **/
    /// \param   int32_t seed
    ///         The seed you want to initialize the generator with.
    AlgorithmMersenneTwister11213A_C( int32_t seed);

    /** default destructor **/
    virtual ~AlgorithmMersenneTwister11213A_C();

    /** virtual function **/
    /** random_init      **/
    //! Initializes the generator with a new seed.
    /// \return void
    /// \param   int32_t seed
    ///         The seed to initialize the generator with.
    virtual void random_init( int32_t seed);

    /** virtual function **/
    /** get_random_int   **/
    //! Returns a random number in the interval [min, max].
    /// \return int32_t
    ///         A number between min and max (inclusive).
    /// \param   int32_t min
    ///         The smallest number allowed.
    /// \param   int32_t max
    ///         The largest number allowed.
    virtual int32_t get_random_int( int32_t min,
                                int32_t max);

    /** virtual function **/
    /** get_random_bytes **/
    //! Return 32 random bits.
    /// \return uint32_t
    ///         32 random bits.
    /// \param  void
    virtual uint32_t get_random_bytes(void);

private:
    //! State vector.
    uint32_t mMt[351];
    //! Index into mMt.
    uint32_t mTi;
    //! Last interval length.
    uint32_t mLastInterval;
    //! Rejection limit.
    uint32_t mRLimit;
};

} // namespace Random
} // namespace Myth

#endif // __MYTH_RANDOM_RANDOM_ALGORITHM_MERSENNE_TWISTER_C_HPP_INCLUDED__

